package com.bingguo.sys.controller;

import com.bingguo.sys.entity.SysUser;
import com.bingguo.sys.service.SysUserService;
import com.bingguo.util.JwtUtil;
import com.bingguo.util.RedisUtil;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
public class LoginController {

    @Resource
    private RedisUtil redisUtil;
    @Resource
    private JwtUtil jwtUtil;

    @Resource
    private SysUserService sysUserService;

    @RequestMapping(value = "login",method = RequestMethod.POST)
    public List<SysUser> Login(@RequestBody SysUser sysUser){

        List<SysUser> sysUserList = sysUserService.getSysUserList();
//        String uuid = UUID.randomUUID().toString();
//        Map<String ,Object> tokenMap = new HashMap<>();
//        tokenMap.put("userId",sysUser.getUserId());
//        tokenMap.put("userName",sysUser.getUserName());
//        tokenMap.put(TokenConstants.UUID,uuid);
//        String token = jwtUtil.createToken(tokenMap);
//        redisUtil.set(TokenConstants.LOGIN_TOKEN_KEY+uuid,token,TokenConstants.EXPIRE);
//        return token;
        return sysUserList;
    }

}
